<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
</head>
<body>
<h1>声明变量</h1>

<script>

    /*
    var num = 100;
    console.info(num);
    console.info(typeof(num));
    num = '100';
    console.info(num);
    console.info(typeof(num));*/


    //函数调用时，隐含着声明了一个全局变量。
    //var num = 100;
    /*
    function fn(){
        num = 100;
    }
    fn();
    console.log(num);*/

    /*
    num = 50;
    function fn(){
        num = 100;
    }
    fn();
    console.log(num);*/

    num = 50;
    function fn(){
        var num = 100; //一定是局部变量
    }
    fn();
    console.log(num);
</script>
</body>
</html>